package com.open.capacity.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.open.capacity.common.model.SttUser;
import com.open.capacity.common.model.SysUser;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
* @author 作者 owen 
* @version 创建时间：2017年11月12日 上午22:57:51
 * 用户管理
 */
@Component
public interface SysUserDao  extends BaseMapper<SttUser> {

	@Options(useGeneratedKeys = true, keyProperty = "straid")
	@Insert("insert into stt_administrators (number, passwd, stname , struri, phones, gender, enable) "
			+ "values(#{username}, #{password}, #{nickname}, #{headImgUrl}, #{phone}, #{sex}, #{enabled})")
	int save(SttUser sysUser);

	int updateByPrimaryKey(SttUser sysUser);

	@Select("select straid id ,number username, passwd password,stname nickname, struri headImgUrl, phones phone, gender sex, enable enabled, crtime createTime, uptime updateTime  from stt_administrators t where t.number = #{username}")
	SttUser findByUsername(String username);

	@Select("select straid id ,number username, passwd password,stname nickname, struri headImgUrl, phones phone, gender sex, enable enabled, crtime createTime, uptime updateTime from stt_administrators  t where t.straid = #{id}")
	SttUser findById(Long id);

	@Select("select straid id ,number username, passwd password,stname nickname, struri headImgUrl, phones phone, gender sex, enable enabled, crtime createTime, uptime updateTime from stt_administrators  u   where u.number = #{username}")
	SttUser findUserByUsername(String username);

	@Select("select straid id ,number username, passwd password,stname nickname, struri headImgUrl, phones phone, gender sex, enable enabled, crtime createTime, uptime updateTime from stt_administrators  u   where u.phones = #{mobile}")
	SttUser findUserByMobile(String mobile);
	
	int count(Map<String, Object> params);

	List<SttUser> findList(Map<String, Object> params);
	
	
	
	

}
